<template>
	<view class="info-content" :style="`height: ${windowHeight}px;`">
		<view class="content">
			<up-cell-group :border="false">
				<up-cell title="头像" :border="false" isLink>
					<template #value>
						<up-avatar :src="userInfo.avatar" size="40"></up-avatar>
					</template>
				</up-cell>
				<up-cell title="真实姓名" :value="userInfo.realName" :border="false" isLink></up-cell>
				<up-cell title="手机号" :value="userInfo.mobile" :border="false" isLink></up-cell>
				<up-cell title="性别" :value="userInfo.gender" :border="false" isLink>
					<!-- <template #value>
							<text v-if="userInfo.gender == 0">男</text>
							<text v-if="userInfo.gender == 1">女</text>
							<text v-if="userInfo.gender == 2">未知</text>
						</view>
						
					</template> -->
				</up-cell>
				<up-cell title="职称名称" :value="userInfo.professionalName" :border="false" isLink></up-cell>
				<up-cell title="职称等级" :value="userInfo.professionalGrade" :border="false" isLink>
			<!-- 		<template #value>
						<view class="custom-value">
							<text v-if="userInfo.professionalGrade == 0">初级</text>
							<text v-if="userInfo.professionalGrade == 1">中级</text>
							<text v-if="userInfo.professionalGrade == 2">高级</text>
						</view>
					</template> -->
				</up-cell>
				<up-cell title="政治面貌" :value="userInfo.politicalStatus" :border="false" isLink>
				<!-- 	<template #value>
						<view class="custom-value">
							<text v-if="userInfo.politicalStatus == 0">中国共产党员</text>
							<text v-if="userInfo.politicalStatus == 1">群众</text>
							<text v-if="userInfo.politicalStatus == 2">中国共青团员</text>
							<text v-if="userInfo.politicalStatus == 3">民主党派</text>
						</view>
					</template> -->
				</up-cell>
				<up-cell title="最高学历" :value="userInfo.educationalBackground" :border="false" isLink>
					<!-- <template #value>
						<view class="custom-value">
							<text v-if="userInfo.educationalBackground == 0">大专及以下</text>
							<text v-if="userInfo.educationalBackground == 1">本科</text>
							<text v-if="userInfo.educationalBackground == 2">硕士</text>
							<text v-if="userInfo.educationalBackground == 3">硕士及以上</text>
						</view>
					</template> -->
				</up-cell>
				<up-cell title="民族" :value="userInfo.nation" :border="false" isLink>
				<!-- 	<template #value>
						<view class="custom-value">
							<text v-if="userInfo.nation == 0">汉族</text>
							<text v-if="userInfo.nation == 2">回族</text>
							<text v-if="userInfo.nation == 3">满族</text>
						</view>
					</template> -->
				</up-cell>
			</up-cell-group>
		</view>
		<view class="content">
			<up-cell title="所属工会" :border="false" isLink>
				<template #value>
					<view style="width: 300rpx;">{{userInfo.orgName}}</view>
				</template>
			</up-cell>
		</view>
		<view class="content">
			<up-cell title="所属部门" :value="deptName" :border="false" isLink></up-cell>
		</view>
	</view>
</template>

<script>
	import { userApi } from '@/api/user/user-api.js';
	import { getDictDataList, getDictLabel } from '@/utils/tool'
	
	
	export default {
		data() {
			return {
				windowHeight: 0,
				userInfo: {},
				deptName: '',
				dictParams: {
					dictTypeId: 2, 
					page: 1,
					limit: 10
				}
			}
		},
		onLoad() {
			this.getDict()
			this.getsize()
			
		},
		methods: {
			getsize(){
			  let that = this
			  uni.getSystemInfo({
				success(res) {
				  that.windowHeight = res.windowHeight
				},
			  })
			},
			async getList() {
				const result = await userApi.getUserInfo()
				// console.log(result)
				// 性别
				let label1 = getDictLabel(JSON.parse(this.$store.state.app.dictList), 'user_gender', result.data.gender)
				result.data.gender = label1
				// 职称等级
				let label2 = getDictLabel(JSON.parse(this.$store.state.app.dictList), 'professional_grade', result.data.professionalGrade)
				result.data.professionalGrade = label2
				// 政治面貌
				let label3 = getDictLabel(JSON.parse(this.$store.state.app.dictList), 'political_status', result.data.politicalStatus)
				result.data.politicalStatus = label3
				// 学历
				let label4 = getDictLabel(JSON.parse(this.$store.state.app.dictList), 'educational_background', result.data.educationalBackground)
				result.data.educationalBackground = label4
				// 民族
				let label5 = getDictLabel(JSON.parse(this.$store.state.app.dictList), 'nation_type', result.data.nation)
				result.data.nation = label5
				
				this.userInfo = result.data
		
				// 查询所属部门
				if (result.data.deptId) {
					this.getDeptList(result.data.deptId)
				}
				
			},
			async getDeptList(deptId) {
				const result = await userApi.getDeptInfo(deptId)
				this.deptName = result.data.deptName
			},
			getDict() {
				this.$store.dispatch('getDictListAction').then((res) => {
					// let userInfo = uni.getStorageSync('userInfo')
					// // userInfo.memberId
					this.getList()
				})
				
			}
		}
	}
</script>

<style scoped lang="scss">
	.info-content {
		background-color: #F5F6FA;
		padding: 30rpx;
		.content {
			border-radius: 20rpx;
			background-color: #fff;
			margin-bottom: 30rpx;
		}
	}
	.custom-value {
		font-size: 14px;
		line-height: 24px;
		color: #606266;
	}
</style>